<template>
  <div>
    <h2>登录页面</h2>
    <table>
      <tr>
        <td>用户名</td>
        <td>
          <input type="text" v-model="state.Uname">
        </td>
      </tr>  
      <tr>
        <td>密码</td>
        <td>
          <input type="text" v-model="state.Upwd">
        </td>
      </tr>  
      <tr>
        <td colspan="2"><input type="button" value="登录" @click="Login"></td>
      </tr>  
    </table>
  </div>
</template>

<script setup lang="ts">
  import router from '@/router';
import axios from 'axios';
import {reactive,toRefs} from 'vue'
  let data=reactive({
    state:{
      Uname:"",
      Upwd:""
    }
  })
  let{state}=toRefs(data)
  function Login()
  {
    axios({
      url:"http://localhost:55351/api/User/GetUserLogin",
      method:"",
      params:state.value
    })
    .then(res=>{
      console.log(res);
      
       if(res.data.data>0)
      {
        alert("登录成功");
        router.push("/FinList")
      }
    })
    .catch(err=>{
      console.log(err)
    })
  }
</script>

<style scoped>

</style>